<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
    <title>Redisgeo 附近定位 示例/说明</title>

    <!-- Bootstrap Core CSS -->
    <link href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">

    <!-- Custom CSS -->
    <link href="__CDN__/assets/css/frontend.css" rel="stylesheet">

    <!-- Plugin CSS -->
    <link href="https://cdn.staticfile.org/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
    <link href="https://cdn.staticfile.org/simple-line-icons/2.4.1/css/simple-line-icons.min.css" rel="stylesheet">

    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
    <script src="https://cdn.staticfile.org/html5shiv/3.7.3/html5shiv.min.js"></script>
    <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>
<body>
<div class="container">
    <div>
        <p> 在其他控制器里使用方法
            $geo = new \addons\redisgeo\controller\Index();
             <br>
            //可以直接调用里面的公共方法即可
            $geo_list = $geo->get_nearby_list(120.0001,36.111,5000,'m',$limit,'ASC');
            <br>
        </p>
    </div>
    <div class="well" style="margin-top:30px;">
        <form class="form-horizontal" id="add_geo" action="{:addon_url('redisgeo/index/test')}" method="POST">
            <fieldset>
                <legend>Redis添加坐标信息</legend>
                <input type="hidden" name="act" value="add_geo">
                <div class="form-group">
                    <label class="col-lg-2 control-label">经度</label>
                    <div class="col-lg-10">
                        <input type="number" class="form-control" id="add_lng" name="lng" placeholder="地图的经度"  min="0.0" step="0.000000001">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-lg-2 control-label">纬度</label>
                    <div class="col-lg-10">
                        <input type="number" class="form-control" id="add_lat" name="lat" placeholder="地图的纬度" min="0.0" step = "0.000000001">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-lg-2 control-label">信息/id</label>
                    <div class="col-lg-10">
                        <input type="text" class="form-control" id="add_id" name="id" placeholder="关键信息（不能重复）一般默认信息的id">
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-lg-10 col-lg-offset-2">
                        <button type="submit" class="btn btn-primary">添加</button>
                        <button type="reset" class="btn btn-default">重置</button>
                    </div>
                </div>
            </fieldset>
        </form>
    </div>





    <div class="well" style="margin-top:30px;">
        <form class="form-horizontal" action="{:addon_url('redisgeo/index/test')}" method="POST">
            <fieldset>
                <legend>Redis删除坐标信息</legend>
                <input type="hidden" name="act" value="del_geo">
             
                <div class="form-group">
                    <label class="col-lg-2 control-label">信息/id</label>
                    <div class="col-lg-10">
                        <input type="text" class="form-control" id="add_id" name="id" placeholder="关键信息（不能重复）一般默认信息的id">
                    </div>
                </div>
               
                <div class="form-group">
                    <div class="col-lg-10 col-lg-offset-2">
                        <button type="submit" class="btn btn-primary">删除</button>
                    </div>
                </div>
            </fieldset>
        </form>
    </div>




    <div class="well" style="margin-top:30px;">
        <form class="form-horizontal" action="{:addon_url('redisgeo/index/index')}" method="POST">
            <fieldset>
                <legend>Redis查询坐标</legend>
                <div class="form-group">
                    <label class="col-lg-2 control-label">经度</label>
                    <div class="col-lg-10">
                        <input type="number" class="form-control" name="lng" placeholder="地图的经度" value="{$lng}" min="0.0" step="0.000000001">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-lg-2 control-label">纬度</label>
                    <div class="col-lg-10">
                        <input type="number" class="form-control" name="lat" placeholder="地图的纬度" value="{$lat}" min="0.0" step="0.000000001">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-lg-2 control-label">多少米范围</label>
                    <div class="col-lg-10">
                        <input type="number" class="form-control" name="m" placeholder="多少米范围" value="{$m}">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-lg-2 control-label">排序</label>
                    <div class="col-lg-10">
                        <input type="text" class="form-control" name="sort" placeholder="可选DESC（降序）  ASC（升序）" value="{$sort}">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-lg-2 control-label">数量</label>
                    <div class="col-lg-10">
                        <input type="number" class="form-control" name="limit" placeholder="要取的个数" value="{$limit}">
                    </div>
                </div>
                
                <div class="form-group">
                    <div class="col-lg-10 col-lg-offset-2">
                        <button type="submit" class="btn btn-primary">刷新</button>
                    </div>
                </div>
            </fieldset>
        </form>


        <table class="table table-striped">
            <thead>
              <tr>
                <th>信息/ID</th>
                <th>经度</th>
                <th>纬度</th>
                <th>距离米</th>
              </tr>
            </thead>
            <tbody>
                {volist name="geo_list" id="v"}
                <tr>
                    <th scope="row">{$v[0]}</th>
                    <td>{$v['geo'][0]}</td>
                    <td>{$v['geo'][1]}</td>
                    <td>{$v[1]}</td>
                </tr>
                {/volist}
              
            </tbody>
          </table>
</div>



<div class="well" style="margin-top:30px;">
    <form class="form-horizontal" action="{:addon_url('redisgeo/index/test')}" method="POST">
        <input type="hidden" name="act" value="query_distance">
        <fieldset>
            <legend>查询2坐标的距离（km）</legend>
            <div class="form-group">
                <label class="col-lg-2 control-label">经度1</label>
                <div class="col-lg-10">
                    <input type="number" class="form-control" name="lng1" placeholder="地图的经度1" value="{$lng}" min="0.0" step="0.000000001">
                </div>
            </div>
            <div class="form-group">
                <label class="col-lg-2 control-label">纬度1</label>
                <div class="col-lg-10">
                    <input type="number" class="form-control" name="lat1" placeholder="地图的纬度1" value="{$lat}" min="0.0" step="0.000000001">
                </div>
            </div>

            <div class="form-group">
                <label class="col-lg-2 control-label">经度2</label>
                <div class="col-lg-10">
                    <input type="number" class="form-control" name="lng2" placeholder="地图的经度2" value="{$lng+1}" min="0.0" step="0.000000001">
                </div>
            </div>
            <div class="form-group">
                <label class="col-lg-2 control-label">纬度2</label>
                <div class="col-lg-10">
                    <input type="number" class="form-control" name="lat2" placeholder="地图的纬度2" value="{$lat+1}" min="0.0" step="0.000000001">
                </div>
            </div>
            
            
            <div class="form-group">
                <div class="col-lg-10 col-lg-offset-2">
                    <button type="submit" class="btn btn-primary">查询</button>
                </div>
            </div>
        </fieldset>
    </form>
</div>




<!-- jQuery -->
<script src="https://cdn.staticfile.org/jquery/2.1.4/jquery.min.js"></script>

<!-- Bootstrap Core JavaScript -->
<script src="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>

<script type="text/javascript">
    $(function () {

    });
</script>
</body>
</html>